package nancal.mp.service.jenkins

import nbcp.base.extend.AsString


fun JenkinsPublishJob.is_root_path(): Boolean {
    return this.task.buildInfo.buildFolder.AsString().any { it.isLetterOrDigit() } == false
}

fun String.catTextContentToFile(fileName: String): String {
    return """
cat << EOF > ${fileName}
${this.replace("＄", "\\\$")}
EOF
"""
}

fun String.catContentToFile(fileName: String): String {
    return """
cat << EOF > ${fileName}
${this.replace("＄", "\\\\\$")}
EOF
"""
}

fun String.sudoExecSh(): String {
    return """sh '''#!/usr/bin/env bash
${
        this.replace("＄", "$")
    }

if [ $? -ne 0 ]; then
    exit 1
fi
'''
"""
}









